﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using mmoss.orm;
using mmoss.configuration;
using mmoss.application.classes;

namespace mmoss.application
{
    public partial class Inventory : Form
    {
        public Inventory()
        {
            InitializeComponent();
            this.Load += new EventHandler(Inventory_Load);
        }

        void Inventory_Load(object sender, EventArgs e)
        {
            gvInventoryItems.AutoGenerateColumns = false;
            cboInventoryType.SelectedIndexChanged += new EventHandler(cboInventoryType_SelectedIndexChanged);
            //load the ddl
            cboInventoryType.DataSource = dbConn.db.InventoryItemTypes;
            cboInventoryType.DisplayMember="InventoryTypeDesc";
            cboInventoryType.ValueMember = "InventoryTypeID";

            //load the datagrid

        }

        void cboInventoryType_SelectedIndexChanged(object sender, EventArgs e)
        {
            //load the latest ones
            gvInventoryItems.DataSource = Default.CurrentLocation.InventoryItemByVendorMMCS.Where(p=>
            p.InventoryItem.InventoryItemType==((InventoryItemType)cboInventoryType.SelectedItem)).Select(p => p.InventoryAdjustmentMMCS
                ).ToList();
            
        }
    }
}
